package com.wufan.day02;

import java.util.Scanner;

/**
 * @author SongWufan
 * @date 2021/3/3 21:50
 */
public class ForTest {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入第一个正数：");
        int m = sc.nextInt();
        System.out.println("请输入第二个正数：");
        int n = sc.nextInt();

        //获取两个数中的较小值
        int min = Math.min(m, n);
        //遍历
        for (int i = min; i >= 1; i--){
            if (m % i == 0 && n % i == 0){
                System.out.println("最大公约数："+i);
                break;
            }
        }
    }
}
